package jjn.acwing.algorithm_basic.chapter1.big_number;

import java.util.*;

public class Acwing792 {
    static List<Integer> strToDigits(String num) {
        int n = num.length();
        List<Integer> res = new ArrayList<>(n);
        for (int i = n - 1; i >= 0; i--) {
            int digit = num.charAt(i) - '0';
            res.add(digit);
        }
        return res;
    }
    
    static void subtract(List<Integer> a, List<Integer> b, Deque<Integer> result) {
        int lent = 0;
        for (int i = 0; i < a.size(); i++) {
            int tobe = (i < b.size()) ? b.get(i) : 0;
            int rest = a.get(i) - tobe - lent;
            if (rest < 0) {
                lent = 1;
            } else {
                lent = 0;
            }
            rest = (rest + 10) % 10;
            result.offer(rest);
        }
        while (result.size() > 1 && Objects.equals(result.peekLast(), 0)) {
            result.pollLast();
        }
    }
    
    static boolean compareTo(String a, String b) {
        if (a.length() != b.length()) {
            return a.length() > b.length();
        }
        for (int i = 0; i < a.length(); i++) {
            int first = a.charAt(i) - '0';
            int second = b.charAt(i) - '0';
            if (first == second) {
                continue;
            }
            return first > second;
        }
        return true;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        List<Integer> arrA = strToDigits(a);
        List<Integer> arrB = strToDigits(b);
        Deque<Integer> result = new ArrayDeque<>();
        boolean flag = true;
        if (compareTo(a, b)) {
            subtract(arrA, arrB, result);
        } else {
            flag = false;
            subtract(arrB, arrA, result);
        }
        if (!flag) {
            System.out.print("-");
        }
        while (!result.isEmpty()) {
            System.out.printf("%d", result.pollLast());
        }
        System.out.println();
    }
}